package AudioUDP;
/**
 * Describe class Player here.
 *
 *
 * Created: Tue Mar 23 10:44:18 2010
 *
 * @author <a href="mailto:stg1@pc111-1.formation-continue.grenoble-inp.fr">stagiaire</a>
 * @version 1.0
 */

import java.io.*;

public  class Player extends Thread{

    /**
     * Creates a new <code>Player</code> instance.
     *
     */
    //FileInputStream fis;
    BufferedOutputStream aos;
    
    
    Player() {
	try{
		String cmd = String.format("play -r 16000 -c 1 -s -2 -t raw -");
		Process play = Runtime.getRuntime().exec(cmd);
		aos = new BufferedOutputStream(play.getOutputStream());
	    //fis = new FileInputStream("lesEtoiles16.raw");
	}catch(Exception e){
	    System.out.println(e);
	}
    }

    void play(byte[] buf){
	//byte [] buf = new byte[640];
	int n;
	
	try{
	    //n = fis.read(buf);
	    //while (n>=0){
		aos.write(buf,0,buf.length);
		//aos.write(buf,0,n);
		//n = fis.read(buf);
	    //}
	}catch(Exception e){
	    System.out.println(e);
	}
    }
    

    /**
     * Describe <code>main</code> method here.
     *
     * @param args a <code>String</code> value
     */


}
